#!/bin/bash

# 检查网络硬件连接
echo "检查网络硬件连接..."
if [ -n "$(lspci | grep Ethernet)" ]; then
    echo "有线网卡已找到"
    else
        echo "未找到有线网卡，请检查硬件连接或安装驱动"
            exit 1
            fi

            if [ -n "$(lspci | grep Wireless)" ] || [ -n "$(lsusb | grep Wireless)" ]; then
                echo "无线网卡已找到"
                else
                    echo "未找到无线网卡，请检查硬件连接或安装驱动"
                        exit 1
                        fi

                        # 检查网络服务状态并重启
                        echo "检查并重启网络服务..."
                        sudo systemctl restart NetworkManager
                        sudo systemctl restart dhcpcd

                        # 检查网络配置
                        echo "检查网络配置..."
                        ip addr show
                        ip route show

                        # 检查DNS设置
                        echo "检查DNS设置..."
                        cat /etc/resolv.conf

                        # 尝试更新系统
                        echo "尝试更新系统..."
                        sudo pacman -Syu

                        echo "修复完成，请检查网络是否恢复正常"
                        